# -*- coding:utf-8 -*-
'''
@Author: lindes
'''
from rest_framework import serializers

from good_article.models import GoodCategory
from post.models import Post, PostImages
from users.models import UserProfile, Focus


class PostImagesSerializer(serializers.ModelSerializer):
    class Meta:
        model = PostImages
        fields = ("id", "image", "add_time")


class PostSerializer(serializers.ModelSerializer):
    images = PostImagesSerializer(many=True)

    class Meta:
        model = Post
        fields = ("id", "title", "author", "content", "images", "add_time", "click_count", "inform_count",
                  "collect_count", "praise_count", "comment_count")


# nizhanzhao
class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserProfile
        fields = ('id', 'name')

class GoodCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodCategory
        fields = ('id','name')

class AllPostSerializer(serializers.ModelSerializer):
    # category = GoodCategorySerializer()
    author = UserSerializer()
    class Meta:
        model = Post
        fields = ('id','title','author','add_time','praise_count')

class FocusSerializer(serializers.ModelSerializer):
    name = UserSerializer()
    class Meta:
        model = Focus
        fields = ('name',)

class FocusPeopleSerializer(serializers.ModelSerializer):
    # category = GoodCategorySerializer()
    user_id_a = FocusSerializer()
    class Meta:
        model = Focus
        fields = ('user_id_a','add_time')